home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / umich / network / ka9q / ka9q_src.arc / UDPDUMP.C < prev    next >
C/C++ Source or Header  |  1988-07-28  |  788b  |  44 lines

  1. #include <stdio.h>
  2. #include "global.h"
  3. #include "mbuf.h"
  4. #include "netuser.h"
  5. #include "internet.h"
  6. #include "udp.h"
  7.  
  8. /* Dump a UDP header */
  9. void
  10. udp_dump(bpp,source,dest,check)
  11. struct mbuf **bpp;
  12. int32 source,dest;
  13. int check;        /* If 0, bypass checksum verify */
  14. {
  15.     struct udp udp;
  16.     struct pseudo_header ph;
  17.     int16 csum;
  18.  
  19.     if(bpp == NULLBUFP || *bpp == NULLBUF)
  20.         return;
  21.  
  22.     printf("UDP:");
  23.  
  24.     /* Compute checksum */
  25.     ph.source = source;
  26.     ph.dest = dest;
  27.     ph.protocol = UDP_PTCL;
  28.     ph.length = len_mbuf(*bpp);
  29.     if((csum = cksum(&ph,*bpp,ph.length)) == 0)
  30.         check = 0;    /* No checksum error */
  31.  
  32.     ntohudp(&udp,bpp);
  33.  
  34.     printf(" %u->%u",udp.source,udp.dest);
  35.     printf(" len %u",udp.length);
  36.     if(udp.checksum == 0)
  37.         check = 0;
  38.     if(check)
  39.         printf(" CHECKSUM ERROR (%u)",csum);
  40.  
  41.     printf("\n");
  42. }
  43.  
  44.